package Ngeplay;

import java.io.BufferedInputStream;
import java.io.FileInputStream;

import javazoom.jl.player.Player;

public class Mp3Player {

	private static String filename;
	private static Player player;

	public static void play() {
	        try {
	            FileInputStream fis     = new FileInputStream("mp3/suara alarm mobil.mp3");
	            BufferedInputStream bis = new BufferedInputStream(fis);
	            player = new Player(bis);
	        }
	        catch (Exception e) {
	            System.out.println("Problem playing file " + filename);
	            System.out.println(e);
	        }

	        // run in new thread to play in background
	        new Thread() {
	            @Override
	            public void run() {
	                try { 
	                      player.play();

	                }
	                catch (Exception e) { System.out.println(e); }
	            }
	        }.start();
	    }
	public void close()
	{
		player.close();
	}
}
